#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

namespace bit
{
	class string
	{
	public:
		typedef char* iterator;
		typedef const char* const_iterator;

		string(const char* s = "")
			:_size(strlen(s))
		{
			_str = new char[_size + 1];
			_capacity = _size;
			strcpy(_str, s);
		}
		string()
			:_str(new char[1])
			, _size(0)
			, _capacity(0)
		{
			_str[0] = '\0';
		}

		~string()
		{
			delete[] _str;
			_size = _capacity = 0;
		}

		string(const string& str)
		{
			_str = new char[str.capacity() + 1];
			_capacity = str.capacity();
			_size = str.size();
			strcpy(_str, str.c_str());
		}

		string& operator=(const string& str)
		{

		}

		char operator[](size_t i) const
		{
			return _str[i];
		}

		void resize(size_t n,char c = '\0')
		{
			if (n < _size)
			{
				_str[n] = '\0';
			}
			else
			{
				reserve(n);
				for (int i = _size; i < n; i++)
				{
					_str[i] = c;
				}
				_size = n;
				_str[n] = '\0';
			}
		}

		void reserve(size_t n)
		{
			if (n > _capacity)
			{
				char* tmp = new char[n + 1];
				strcpy(tmp, _str);
				delete[] _str;
				_str = tmp;

				_capacity = n;
			}
		}

		size_t capacity() const
		{
			return _capacity;
		}

		size_t size() const
		{
			return _size;
		}

		char* c_str() const
		{
			return _str;
		}

	private:
		char* _str;
		size_t _size;
		size_t _capacity;
	};
}

int main()
{
	cout << "hello world" << endl;

	return 0;
}